//index.js
//获取应用实例
var app = getApp()
var wxSortPickerView = require('../../wxSortPickerView/wxSortPickerView.js');
const util = require('../../utils/util.js');
Page({
    data: {
        testArr: []
    },
    onLoad: function(options) {
        var that = this
        that.setData({
            isChinese: wx.getStorageSync("isChinese")
        })
        wx.setNavigationBarTitle({
            title: that.data.isChinese ? "选择城市" : "Choose a city"
        })
        if (options.isTpe) {
            app.getApi.getProducts("POST", {
                method: "opg.city.find",
                pageSize: 0
            }).then(data => {
                that.setData({
                    testArr: data.data.result
                })
                that.setData({
                    isType: options.isTpe,
                    temABC: wxSortPickerView.temABC
                })
                wxSortPickerView.init(that.data.testArr, that);
            })

        }
    },
    wxSortPickerViewItemTap: function(e) {
        if (this.data.isType == 1) {
            wx.setStorageSync("areaName", e.currentTarget.dataset.countryname)
            wx.setStorageSync("areaId", e.currentTarget.dataset.id)
            wx.setStorageSync("country", e.currentTarget.dataset.country)
            app.globalData.ifIndexOnshow = 1
        } else {
            wx.setStorageSync("areaCode", e.currentTarget.dataset.text)
        }

        wx.navigateBack({
            delta: 1
        })

    }
})